<?php
namespace app\admin\controller;
use app\admin\controller\Base;
use app\admin\model\StaffsModel as M;
use \think\Session;
use \think\Request;
use \think\Cache;
class Index extends Base
{
    //判断是否登录过.登录过跳到首页，没有登录显示登录页面
    public function index()
    {
        $this->isLogin();
        $id = Session::get('STAFF.staff_id');
        //超级管理员才能拥有的权限判断
        $this->assign('id',$id);
        return $this->fetch('/index');
    }
    public function show(){
        return $this->fetch('/show');
    }
    //退出清除session
    public function loginOut(){
        Session::clear();
        Cache::clear();
        $this->redirect('admin/Index/login');
    }
    // 登录获取权限
   public function login(){
       if(Request::instance()->isAjax()){
           $m = new M();
           //权限结果集
           $res = $m->checkLogin();
           return $res;
       }else{
          return $this->fetch('/login');
       }
   }

}
